<?php

/**
* SendImageTest.php
*
* Show slide test
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/
require_once '../framework/config.php';

require_once 'simpletest/autorun.php';
require_once 'simpletest/web_tester.php';

require_once '../ShowSlide.class.php';

class  SendImageTest extends WebTestCase
{
    private $url,$fileName;

    public function setUp() 
    {
        $option = &PEAR::getStaticProperty('CONFIG_INI','UPLOAD');
        $this->fileName = $option['upload_dir'].'images.jpg';

        $this->assertTrue( copy('images.jpg', $this->fileName ) );

        $global = &PEAR::getStaticProperty('CONFIG_INI','GLOBAL');
        $this->url = $global['service_url'];
        $this->addHeader("User-Agent: Mozilla/5.0 (iPhone");
        
    }

    public function testSendJpgFile()
    {    
        $this->get($this->url.'send_image.php?&id=images.jpg');
        $this->assertHeader('Content-type','image/jpeg');
        $this->assertHeader('X-new-size','320x200');
    }

    public function testSendNoFileName()
    {
        $this->get($this->url.'send_image.php?&id=');
        $this->assertHeader('Content-type','text/html');
        $this->assertText('Critical User Error !') ;
    }

    public function tearDown() 
    {
        $this->assertTrue( unlink($this->fileName) );
    }
    
}
?>
